package com.net.xpay.core.enums;

import com.net.common.enums.base.StringEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 2020/5/7 16:46

 */
@Slf4j
@Getter
@AllArgsConstructor
public enum PayTransBatchStatus implements StringEnum<PayTransBatchStatus> {
    IMPORTED("IMPORTED", "已导入"),

    INIT("INIT", "批次已接收"),
    WAIT_PAY("WAIT_PAY", "等待付款"),
    DEALING("DEALING", "批次处理中"),
    SUCCESS("SUCCESS", "批次全部处理成功"),
    PART_SUCCESS("PART_SUCCESS", "批次部分处理成功"),
    FAIL("FAIL", "全部处理失败"),
    INVALID("INVALID", "批次无效"),
    DISUSE("DISUSE", "批次废弃"),
    UNKNOWN("UNKNOWN", "未知")
    ;

    public static PayTransBatchStatus of(String status) {
        try {
            return PayTransBatchStatus.valueOf(status);
        } catch (Exception e) {
            log.error("of error|status={}", status);
            return UNKNOWN;
        }
    }


    private String value;

    private String desc;

    public static boolean isFinalStatus(PayTransBatchStatus status) {
        return status == SUCCESS || status == PART_SUCCESS || status == FAIL || status == INVALID || status == DISUSE;
    }
}
